<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@ include file="/taglibs.jsp"%>
<s:url value="/images" var="imgPath"/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<script language="javascript">
$().ready( function() {
	var error = 0;
	$("input[name=pid]").each(function(index){
		var key = $(this).val();
		//alert(parseFloat($("#shelfPrice_"+key).val())-parseFloat($("#price3_"+key).val()));
		if(parseFloat($("#shelfPrice_"+key).val())-parseFloat($("#price3_"+key).val())<0){
			$("#shelfPriceError_"+key).show();
			error++;
		}			
					
	});		
	$("#negativePrice").val(error);
});
function sumbitF(){
	if(parseFloat($("#negativePrice").val())>0){
		if(confirm("上架售价小于商品成本价，确定新增批次吗?")){
			$("#doneForm").submit();
		}else{
			return;
		}
	}else{
		$("#doneForm").submit();
	}
}
</script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<link rel="stylesheet" type="text/css" href="/css/jquery-ui-1.7.2.custom.css"/>
<s:actionerror cssClass="errmsg"/>
<s:actionmessage cssClass="errmsg"/>
  <h1>核对资料/完成编辑 - 批次新增上架檔</h1>
  <div class="batchstep">
    <div class="batchstep-3">
      <span class="step1">Step 1：查寻商品/选取商品</span>
      <span class="step2">Step 2：编辑资料</span>
      <span class="onstep3">Step 3：核对资料/完成编辑</span>
    </div>
  </div>
<input type="hidden" id="negativePrice"/>
      <s:form action="done.do" onsubmit="return false;" id="doneForm">
      <s:hidden name="paramBatchEventId"/>
	  <div class="tipmsg"><ul><li>系统会在你所指定的时间开始排程，并非开始执行。</li></ul></div>
        <h3 class="tword">请选择此批次开始排程时间：</h3>
		<table class="tb-edit">
          <tr>
          	<th>批次排程时间</th><td>
          	<s:radio list="#{'true':'立即排程'}" name="paramExecuteNow" listKey="key" listValue="value" value="true"/></td>
          </tr>          
        </table>
		<br /><a href="edit.do" class="pstep">﹤回上一步</a> 
		<input type="button" value="核对无误，确认送出" name="submit1" class="nstep" onclick="sumbitF();">
      <br />
      <h3 class="tword">请核对你所套用的 ${fn:length(detailMap)} 笔资料：</h3>
	  <table width="100%" class="tb-1">
        <thead>
          <tr>
          <th>商品编号</th>
          <th>商品名称</th>
          <th>主分类</th>
          <th>厂商建议售价</th>
          <th>提报耀点价</th>
          <th>商品成本</th>
          <th>商品促銷小標</th>
          <th>上架起始日期时间</th>
          <th>上架结束日期时间</th>
          <th>上架售价</th>
        </tr></thead>
        <tbody>

        <c:forEach items="${detailMap}" var="map" varStatus="rows_index" begin="${pager.startRecord}" end="${pager.endRecord}">
          <tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">       
           <td>${map.key}<input type="hidden" name="pid" value="${map.key}"></td>
           <td style="text-align:left;">${map.value.dataOldMap['productName']}</td>
<!--           <td>${map.value.dataOldMap['supplierId']}</td>-->
           <td style="text-align:left;">${map.value.dataOldMap['mainCategoryPathDesc']}</td>
<!--           <td>${map.value.dataOldMap['isDelete']}</td>-->
           <td>${map.value.dataOldMap['listPrice']}<input type="hidden" id="price1_${map.key}" value="${map.value.dataOldMap['listPrice']}"></td>
           <td>${map.value.dataOldMap['prpsShelfPrice']}<input type="hidden" id="price2_${map.key}" value="${map.value.dataOldMap['prpsShelfPrice']}"></td>
           <td>${map.value.dataOldMap['productCost']}<input type="hidden" id="price3_${map.key}" value="${map.value.dataOldMap['productCost']}"></td>
           <td><span class="txt-red">${fn:trim(map.value.dataNewMap['promoteName'])==''?'-':map.value.dataNewMap['promoteName']}</span></td>
           <td><span class="txt-red">${map.value.dataNewMap['startDate']}</span></td>
           <td><span class="txt-red">${map.value.dataNewMap['endDate']}</span></td>
           <td><span class="txt-red">${map.value.dataNewMap['shelfPrice']}</span><input type="hidden" id="shelfPrice_${map.key}" value="${map.value.dataNewMap['shelfPrice']}"><div class="errmsg" id="shelfPriceError_${map.key}" style="display:none"><ul><li><span>负毛利</span></li></ul></div></td>
          </tr></c:forEach>      
        </tbody>
      </table>
      <yaodian100:pageutil link="confirm.do" pagerObj="${pager}" />
      <br /><a href="edit.do" class="pstep">﹤回上一步</a> 
      <input type="button" value="核对无误，确认送出" name="submit1" class="nstep" onclick="sumbitF();"><br />
    </s:form>